package com.yyds.controller;


import com.yyds.common.MyJSON;
import com.yyds.common.R;
import com.yyds.pojo.NewsComments;
import com.yyds.service.NewsCommentsService;
import com.yyds.vo.NewsCommentsVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/admin/news/comments")
@SuppressWarnings({"all"})//抑制警告
public class NewsCommentsController {

    @Autowired
    NewsCommentsService newsCommentsService;
    public void setNewsCommentsService(NewsCommentsService newsCommentsService) {
        this.newsCommentsService = newsCommentsService;
    }

//    @RequestMapping("/list")
//    public MyJSON<NewsComments> list(NewsComments newsComments, Integer page, Integer limit){
//        return newsCommentsService.selectAllNewsCommentsService(newsComments,page,limit);
//    }

    @RequestMapping("/list")
    public MyJSON<NewsCommentsVo> list(NewsCommentsVo newsCommentsVo, Integer page, Integer limit){
        return newsCommentsService.selectAllNewsCommentsService(newsCommentsVo,page,limit);
    }

    @RequestMapping("/add")
    public R add(NewsComments newsComments){
        return newsCommentsService.insertNewsCommentsService(newsComments);
    }

    @RequestMapping("/delAll")
    public R delAll(@RequestBody List<NewsComments> list){
        System.out.println("进入删除多条评论 list="+list);
        return newsCommentsService.deleteAllNewsCommentsService(list);
    }

    @RequestMapping("/del")
    public R del(Integer comments_id){
        System.out.println("进入删除一条评论 comments_id="+comments_id);
        return newsCommentsService.deleteNewsCommentsService(comments_id);
    }

    @RequestMapping("query")
    public R query(Integer comments_id){
        return newsCommentsService.selectNewsCommentsService(comments_id);
    }

    @RequestMapping("edit")
    public R edit(NewsComments newsComments){
        return newsCommentsService.updateNewsCommentsService(newsComments);
    }

}
